import Vue from 'vue'
import Alert from './alert.vue'
//const AlertConstructor = Vue.extend(require('./alert.vue').default) // 直接将Vue组件作为Vue.extend的参数
//
//let nId = 1
//
//const Alert = (content) => {
//
//const AlertInstance = new AlertConstructor({
//  data: {
//    content: content,
//    type:1
//  }
//}) // 实例化一个带有content内容的Alert
//
////AlertInstance.id = id
//AlertInstance.vm = AlertInstance.$mount() // 挂载但是并未插入dom，是一个完整的Vue实例
//AlertInstance.vm.isshow = true
//AlertInstance.dom = AlertInstance.vm.$el
//document.body.appendChild(AlertInstance.dom) // 将dom插入body
////AlertInstance.dom.style.zIndex = nId + 1001 // 后插入的Notice组件z-index加一，保证能盖在之前的上面
//return AlertInstance.vm
//}
//
//
//export default {
//install: Vue => {
//  Vue.prototype.$alert = Alert // 将Alert组件暴露出去，并挂载在Vue的prototype上
//}
//}
function install(Vue) {
 
    Object.defineProperty(Vue.prototype, '$alert', {
        get() {
            let div = document.createElement('div')
            document.body.appendChild(div);
            return (content, alertSure) => {
                const Constructor = Vue.extend(Alert)
                const Instance = new Constructor({
                    data() {
                        return {
                            content: content,
                            type:1,
                            isshow: true
                        }
                    },
                    methods: {
                        alertSure: alertSure?alertSure:()=>console.log()//确定方法
                    }
                }).$mount(div);
            };
        }
    });
}
 
export default install
